package com.justech.mes.v2.dao.repository;

import com.justech.mes.v2.model.MesUserAbnormalTimeRecord;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 个人异常工时记录
 *
 * @author feifei.li
 */
@Repository
public interface MesUserAbnormalTimeRecordRepository extends CrudRepository<MesUserAbnormalTimeRecord, Long> {

    /**
     * 查询用户是否有未解除的异常
     *
     * @param userName
     * @return
     */
    List<MesUserAbnormalTimeRecord> findByUserNameAndEndTimeIsNull(String userName);

    /**
     * 获取某个异常
     *
     * @param abnormalUuid 异常记录的唯一标识
     * @return
     */
    List<MesUserAbnormalTimeRecord> findByAbnormalUuid(String abnormalUuid);

    /**
     * 根据UUID获取未被解除的异常记录
     *
     * @param abnormalUuid
     * @return
     */
    List<MesUserAbnormalTimeRecord> findByAbnormalUuidAndEndTimeIsNull(String abnormalUuid);

    /**
     * 根据用户工号和异常id获取异常
     *
     * @param abnormalUuid
     * @param userName
     * @return
     */
    MesUserAbnormalTimeRecord findByAbnormalUuidAndUserName(String abnormalUuid, String userName);
}
